<template>
    <div id="app">
        <el-scrollbar ref="elscrollbar">
            <heard-nav-my class="heard-nav" :class="[$store.getters.getHeardState?'fixed-top':'']"></heard-nav-my>
            <div class="embed-responsive embed-responsive-21by9">
                <div class="embed-responsive-item">
                    <carousel></carousel>
                    <!--<div class="container-self homepage_channelnav"></div>-->
                    <div class="shade"></div>
                </div>
            </div>
            <div class="container-self show-list">
                <div class="module_mod">
                    <div class="module_module_header d-flex flex-row align-items-center">
                        <h2>正在热播</h2>
                        <div class="module_sub_title">
                            <a class="cu-text-blue">“辟谣”入口</a>
                            <a class="cu-text-blue">“求助”入口</a>
                            <a class="cu-text-blue">海淀战“疫”纪实 | 为爱逆行，为家园而战</a>
                        </div>
                        <a href="#" class="cu-text-blue load"><span class="iconfont icon-load"></span>换一换</a>
                    </div>
                    <sm></sm>
                </div>

                <div class="module_mod" style="max-height: 400px">
                    <md-container></md-container>
                </div>
                <div class="module_mod">
                    <lg></lg>
                </div>
            </div>
        </el-scrollbar>
    </div>
</template>
<script>
    import heardNavMy from './components/HeardNav.vue'; // 头部
    import carousel from './components/carousel/carousel.vue'; // 轮播
    import sm from './components/showlist/sm.vue';
    import mdContainer from './components/showlist/mdContainer.vue';
    import lg from './components/showlist/lg.vue';
    export default {
        data(){return{

        }},
        methods:{
            scrollbarWatch(){
                var div = this.$refs['elscrollbar'].$refs['wrap'];
                let distance=200,tag=true;
                div.addEventListener('scroll',()=>{
                    if(div.scrollTop>distance && tag){
                        this.$store.commit('upHeardIsFixedTop',true);
                        tag=false;
                    }else if(div.scrollTop<distance && !tag) {
                        this.$store.commit('upHeardIsFixedTop',false);
                        tag=true;
                    }
                })

            }
        },
        components:{
            heardNavMy,
            carousel,
            sm,
            mdContainer,
            lg
        },
        mounted:function () {
            this.scrollbarWatch()
        }
    }
</script>
<style lang="scss" scoped>
@keyframes shiftDown{
    from{
        transform:translateY(-100%);
    }
    to{
        transform:translateY(0);
    }
}
#app{
    height: 100%;
    .el-scrollbar{
        height: 100%;
        background-color: black;
        /deep/ .el-scrollbar__wrap{
            overflow-x: hidden;
        }
    }
    .heard-nav{
        z-index: 100;
    }
    .fixed-top{
        animation:shiftDown .3s forwards;
    }
    .embed-responsive{
        margin-top: -70px;
        min-height: 412px;
        &:before{
            padding-top:36.99%
        }
        .shade{
            position: absolute;
            bottom: 0;
            height: 60px;
            width: 100%;
            background-image: linear-gradient(to bottom,rgba(0,0,0,0),rgba(0,0,0,0.6),rgba(0,0,0,1));
            z-index: 15;
        }
    }
    .homepage_channelnav{
        height: 90px;
        position: absolute;
        bottom: 0;
        z-index: 10;
        left: 50%;
        transform: translate(-50%,0);
    }
    .show-list{
        .module_mod{
            overflow: hidden;
        }
        .module_module_header{
            color: hsla(0,0%,100%,.87);
            height: 40px;
            position: relative;
            margin-bottom: 10px;
            h2{
                display: inline-block;
                margin: 0;
                line-height: 150%;
                font-size: 26px;
            }
            .module_sub_title{
                a{
                    margin-right: 2px;
                    padding: 0 10px;
                    color: hsla(0,0%,100%,.5);
                }
            }
            .load{
                position: absolute;
                right: 0;
                top: 50%;
                color: hsla(0,0%,100%,.5);
                font-size: 14px;
                text-decoration:none;
                line-height: 40px;
                transform: translate(0,-50%);
                span{
                    margin-right: 10px;
                    font-size: 14px;
                    font-weight: bold;
                }
            }

        }
    }

}
</style>
<style>
    /*滑块背景色*/
    .el-scrollbar__bar.is-vertical>div{
        background-color: #f4f4f4;
    }
    .el-scrollbar__bar.is-vertical{z-index: 20;width: 8px!important;}
</style>
